package com.travelshare.common.core.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.travelshare.common.core.domain.entity.SysDept;
import com.travelshare.common.core.domain.entity.SysMenu;
import com.travelshare.common.core.domain.entity.TreeColumnModel;
import com.travelshare.common.core.domain.entity.TreeDetailReview;

/**
 * Treeselect树结构实体类
 * 
 * @author travelshare
 */
public class TreeSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;
    
    private String isPic;
    
    private String icon;
    
    private Integer reviewType;
    
	private String nickName;
    private Long detailId;
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;

    public TreeSelect()
    {

    }

    public TreeSelect(SysDept dept)
    {
        this.id = dept.getDeptId();
        this.label = dept.getDeptName();
        this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(SysMenu menu)
    {
        this.id = menu.getMenuId();
        this.label = menu.getMenuName();
        this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }
    
    public TreeSelect(TreeColumnModel treeColumnModel)
    {
        this.id = treeColumnModel.getColumnId();
        this.label = treeColumnModel.getColumnName();
        this.isPic = treeColumnModel.getIsPic();
        this.icon = treeColumnModel.getColumIcon();
        this.children = treeColumnModel.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }
    
    public TreeSelect(TreeDetailReview treeDetailReview)
    {
        this.id = treeDetailReview.getReviewId();
        this.label = treeDetailReview.getContent();
        this.reviewType = treeDetailReview.getReviewType();
        this.icon = treeDetailReview.getAvatar();
        this.nickName = treeDetailReview.getNickName();
        this.createTime = treeDetailReview.getCreateTime();
        this.detailId = treeDetailReview.getDetailId();
        this.children = treeDetailReview.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public Long getDetailId() {
		return detailId;
	}

	public void setDetailId(Long detailId) {
		this.detailId = detailId;
	}

	public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getLabel()
    {
        return label;
    }

    public void setLabel(String label)
    {
        this.label = label;
    }

    public String getIsPic() {
		return isPic;
	}

	public void setIsPic(String isPic) {
		this.isPic = isPic;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public List<TreeSelect> getChildren()
    {
        return children;
    }

    public void setChildren(List<TreeSelect> children)
    {
        this.children = children;
    }

	public Integer getReviewType() {
		return reviewType;
	}

	public void setReviewType(Integer reviewType) {
		this.reviewType = reviewType;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
}
